package main.components;

import javax.swing.*;
import java.awt.*;

public class StatusBar extends JPanel {

    public StatusBar() {
        setLayout(new GridBagLayout());
        setPreferredSize(new Dimension(10, 23));

        JPanel rightPanel = new JPanel(new GridBagLayout());
        rightPanel.add(new JLabel(new AngledLinesWindowsCornerIcon()), new GridBagConstraints(0, 0, 1, 1, 0.1, 0.1, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        rightPanel.setOpaque(false);

        add(rightPanel, new GridBagConstraints(8, 0, 1, 1, 0.1, 0.1, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        setBackground(new Color(130, 130, 130));
    }

    protected void paintComponent(Graphics g) {
        super.paintComponent(g);

        int y = 0;
        g.setColor(new Color(130, 130, 130));
        g.drawLine(0, y, getWidth(), y);
        y++;
        g.setColor(new Color(130, 130, 130));
        g.drawLine(0, y, getWidth(), y);
        y++;
        g.setColor(new Color(130, 130, 130));
        g.drawLine(0, y, getWidth(), y);
        y++;
        g.setColor(new Color(150, 150, 150));
        g.drawLine(0, y, getWidth(), y);

        y = getHeight() - 3;
        g.setColor(new Color(130, 130, 130));
        g.drawLine(0, y, getWidth(), y);
        y++;
        g.setColor(new Color(130, 130, 130));
        g.drawLine(0, y, getWidth(), y);
        y = getHeight() - 1;
        g.setColor(new Color(130, 130, 130));
        g.drawLine(0, y, getWidth(), y);

    }

}

class AngledLinesWindowsCornerIcon implements Icon {
    //private static final Color WHITE_LINE_COLOR = new Color(100, 100, 100);
    private static final Color WHITE_LINE_COLOR = Color.white;

    //private static final Color GRAY_LINE_COLOR = new Color(120, 120, 120);
    private static final Color GRAY_LINE_COLOR = Color.gray;
    private static final int WIDTH = 13;

    private static final int HEIGHT = 13;

    public int getIconHeight() {
        return WIDTH;
    }

    public int getIconWidth() {
        return HEIGHT;
    }

    public void paintIcon(Component c, Graphics g, int x, int y) {

        g.setColor(WHITE_LINE_COLOR);
        g.drawLine(0, 12, 12, 0);
        g.drawLine(5, 12, 12, 5);
        g.drawLine(10, 12, 12, 10);

        g.setColor(GRAY_LINE_COLOR);
        g.drawLine(1, 12, 12, 1);
        g.drawLine(2, 12, 12, 2);
        g.drawLine(3, 12, 12, 3);

        g.drawLine(6, 12, 12, 6);
        g.drawLine(7, 12, 12, 7);
        g.drawLine(8, 12, 12, 8);

        g.drawLine(11, 12, 12, 11);
        g.drawLine(12, 12, 12, 12);

    }
}
